package Demo;

//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

import org.apache.bcel.generic.*;

import java.util.ArrayList;
import java.util.Random;

public class Predicates {
    protected int EVEN_OP = 0;
    protected int ODD_OP = 1;
    protected int USE_CONSTS = 0;
    protected int USE_RANK = 1;
    final int OP_1 = 0;
    final int OP_2 = 1;
    final int OP_3 = 2;
    final int OP_4 = 3;
    final int OP_5 = 4;
    final int OP_6 = 5;
    final int OP_7 = 6;
    final int OP_8 = 7;
    final int OP_9 = 8;
    protected int OP_1_CONSTS = 8;
    protected int OP_2_CONSTS = 4;
    protected int OP_3_CONSTS = 3;
    protected int OP_4_CONSTS = 0;
    protected int OP_5_CONSTS = 6;
    protected int OP_6_CONSTS = 8;
    protected int OP_7_CONSTS = 88;
    protected int OP_8_CONSTS = 27;
    protected int OP_9_CONSTS = 6;
    protected int NUM_OPS = 9;
    protected int[] EVEN_OPS = new int[]{0, 1, 3, 4, 5, 6, 8};
    protected int[] ODD_OPS = new int[]{2, 7};
    Random op_generator = new Random();
    ArrayList constOP = new ArrayList();
    int op_used;

    public Predicates() {
        this.constOP.add(8);
        this.constOP.add(4);
        this.constOP.add(3);
        this.constOP.add(0);
        this.constOP.add(6);
        this.constOP.add(8);
        this.constOP.add(88);
        this.constOP.add(27);
        this.constOP.add(6);
    }

    private InstructionList createOP1(int var1, int var2, int coefficient) {
        InstructionList il = new InstructionList();
        il.append(new ILOAD(var2));
        il.append(new ILOAD(var2));
        il.append(new IMUL());
        il.append(new BIPUSH((byte)7));
        il.append(new IMUL());
        il.append(new ICONST(1));
        il.append(new ISUB());
        if (coefficient <= 5 && coefficient >= -1) {
            il.append(new ICONST(coefficient));
        } else if (coefficient < 128 && coefficient >= -128) {
            il.append(new BIPUSH((byte)coefficient));
        } else {
            il.append(new SIPUSH((short)coefficient));
        }

        il.append(new IMUL());
        il.append(new ILOAD(var1));
        il.append(new ILOAD(var1));
        il.append(new IMUL());
        if (coefficient <= 5 && coefficient >= -1) {
            il.append(new ICONST(coefficient));
        } else if (coefficient < 128 && coefficient >= -128) {
            il.append(new BIPUSH((byte)coefficient));
        } else {
            il.append(new SIPUSH((short)coefficient));
        }

        il.append(new IMUL());
        il.append(new IF_ICMPEQ((InstructionHandle)null));
        return il;
    }

    private InstructionList createOP2(int var1, int coefficient) {
        InstructionList il = new InstructionList();
        il.append(new ILOAD(var1));
        il.append(new ILOAD(var1));
        il.append(new IMUL());
        il.append(new ICONST(2));
        il.append(new IDIV());
        if (coefficient <= 5 && coefficient >= -1) {
            il.append(new ICONST(coefficient));
        } else if (coefficient < 128 && coefficient >= -128) {
            il.append(new BIPUSH((byte)coefficient));
        } else {
            il.append(new SIPUSH((short)coefficient));
        }

        il.append(new IMUL());
        il.append(new ICONST(2));
        if (coefficient <= 5 && coefficient >= -1) {
            il.append(new ICONST(coefficient));
        } else if (coefficient < 128 && coefficient >= -128) {
            il.append(new BIPUSH((byte)coefficient));
        } else {
            il.append(new SIPUSH((short)coefficient));
        }

        il.append(new IMUL());
        il.append(new IREM());
        il.append(new IFNE((InstructionHandle)null));
        return il;
    }

    private InstructionList createOP3(int var1, int coefficient) {
        InstructionList il = new InstructionList();
        il.append(new ILOAD(var1));
        il.append(new ILOAD(var1));
        il.append(new ICONST(1));
        il.append(new IADD());
        il.append(new IMUL());
        if (coefficient <= 5 && coefficient >= 1) {
            il.append(new ICONST(coefficient));
        } else if (coefficient < 128 && coefficient >= -128) {
            il.append(new BIPUSH((byte)coefficient));
        } else {
            il.append(new SIPUSH((short)coefficient));
        }

        il.append(new IMUL());
        il.append(new ICONST(2));
        if (coefficient <= 5 && coefficient >= -1) {
            il.append(new ICONST(coefficient));
        } else if (coefficient < 128 && coefficient >= -128) {
            il.append(new BIPUSH((byte)coefficient));
        } else {
            il.append(new SIPUSH((short)coefficient));
        }

        il.append(new IMUL());
        il.append(new IREM());
        il.append(new IFNE((InstructionHandle)null));
        return il;
    }

    private InstructionList createOP4(int var1, int coefficient) {
        InstructionList il = new InstructionList();
        il.append(new ILOAD(var1));
        il.append(new ILOAD(var1));
        il.append(new IMUL());
        if (coefficient <= 5 && coefficient >= -1) {
            il.append(new ICONST(coefficient));
        } else if (coefficient < 128 && coefficient >= -128) {
            il.append(new BIPUSH((byte)coefficient));
        } else {
            il.append(new SIPUSH((short)coefficient));
        }

        il.append(new IMUL());
        il.append(new ICONST(0));
        if (coefficient <= 5 && coefficient >= -1) {
            il.append(new ICONST(coefficient));
        } else if (coefficient < 128 && coefficient >= -128) {
            il.append(new BIPUSH((byte)coefficient));
        } else {
            il.append(new SIPUSH((short)coefficient));
        }

        il.append(new IMUL());
        il.append(new IF_ICMPLT((InstructionHandle)null));
        return il;
    }

    private InstructionList createOP5(int var1, int coefficient) {
        InstructionList il = new InstructionList();
        il.append(new ILOAD(var1));
        il.append(new ILOAD(var1));
        il.append(new ICONST(1));
        il.append(new IADD());
        il.append(new ILOAD(var1));
        il.append(new ICONST(2));
        il.append(new IADD());
        il.append(new IMUL());
        il.append(new IMUL());
        if (coefficient <= 5 && coefficient >= -1) {
            il.append(new ICONST(coefficient));
        } else if (coefficient < 128 && coefficient >= -128) {
            il.append(new BIPUSH((byte)coefficient));
        } else {
            il.append(new SIPUSH((short)coefficient));
        }

        il.append(new IMUL());
        il.append(new ICONST(3));
        if (coefficient <= 5 && coefficient >= -1) {
            il.append(new ICONST(coefficient));
        } else if (coefficient < 128 && coefficient >= -128) {
            il.append(new BIPUSH((byte)coefficient));
        } else {
            il.append(new SIPUSH((short)coefficient));
        }

        il.append(new IMUL());
        il.append(new IREM());
        il.append(new IFNE((InstructionHandle)null));
        return il;
    }

    private InstructionList createOP6(int var1, int coefficient) {
        InstructionList il = new InstructionList();
        il.append(new ILOAD(var1));
        il.append(new ILOAD(var1));
        il.append(new IMUL());
        il.append(new ICONST(1));
        il.append(new IADD());
        if (coefficient <= 5 && coefficient >= -1) {
            il.append(new ICONST(coefficient));
        } else if (coefficient < 128 && coefficient >= -128) {
            il.append(new BIPUSH((byte)coefficient));
        } else {
            il.append(new SIPUSH((short)coefficient));
        }

        il.append(new IMUL());
        il.append(new BIPUSH((byte)7));
        if (coefficient <= 5 && coefficient >= 1) {
            il.append(new ICONST(coefficient));
        } else if (coefficient < 128 && coefficient >= -128) {
            il.append(new BIPUSH((byte)coefficient));
        } else {
            il.append(new SIPUSH((short)coefficient));
        }

        il.append(new IMUL());
        il.append(new IREM());
        il.append(new IFEQ((InstructionHandle)null));
        return il;
    }

    private InstructionList createOP7(int var1, int coefficient) {
        InstructionList il = new InstructionList();
        il.append(new ILOAD(var1));
        il.append(new ILOAD(var1));
        il.append(new IMUL());
        il.append(new ILOAD(var1));
        il.append(new IADD());
        il.append(new BIPUSH((byte)7));
        il.append(new IADD());
        if (coefficient <= 5 && coefficient >= -1) {
            il.append(new ICONST(coefficient));
        } else if (coefficient < 128 && coefficient >= -128) {
            il.append(new BIPUSH((byte)coefficient));
        } else {
            il.append(new SIPUSH((short)coefficient));
        }

        il.append(new IMUL());
        il.append(new BIPUSH((byte)81));
        if (coefficient <= 5 && coefficient >= -1) {
            il.append(new ICONST(coefficient));
        } else if (coefficient < 128 && coefficient >= -128) {
            il.append(new BIPUSH((byte)coefficient));
        } else {
            il.append(new SIPUSH((short)coefficient));
        }

        il.append(new IMUL());
        il.append(new IREM());
        il.append(new IFEQ((InstructionHandle)null));
        return il;
    }

    private InstructionList createOP8(int var1, int coefficient) {
        InstructionList il = new InstructionList();
        il.append(new ICONST(4));
        il.append(new ILOAD(var1));
        il.append(new ILOAD(var1));
        il.append(new IMUL());
        il.append(new IMUL());
        il.append(new ICONST(4));
        il.append(new IADD());
        if (coefficient <= 5 && coefficient >= -1) {
            il.append(new ICONST(coefficient));
        } else if (coefficient < 128 && coefficient >= -128) {
            il.append(new BIPUSH((byte)coefficient));
        } else {
            il.append(new SIPUSH((short)coefficient));
        }

        il.append(new IMUL());
        il.append(new BIPUSH((byte)19));
        if (coefficient <= 5 && coefficient >= -1) {
            il.append(new ICONST(coefficient));
        } else if (coefficient < 128 && coefficient >= -128) {
            il.append(new BIPUSH((byte)coefficient));
        } else {
            il.append(new SIPUSH((short)coefficient));
        }

        il.append(new IMUL());
        il.append(new IREM());
        il.append(new IFEQ((InstructionHandle)null));
        return il;
    }

    private InstructionList createOP9(int var1, int coefficient) {
        InstructionList il = new InstructionList();
        il.append(new ILOAD(var1));
        il.append(new ILOAD(var1));
        il.append(new IMUL());
        il.append(new ILOAD(var1));
        il.append(new ICONST(1));
        il.append(new IADD());
        il.append(new IMUL());
        il.append(new ILOAD(var1));
        il.append(new ICONST(1));
        il.append(new IADD());
        if (coefficient <= 5 && coefficient >= -1) {
            il.append(new ICONST(coefficient));
        } else if (coefficient < 128 && coefficient >= -128) {
            il.append(new BIPUSH((byte)coefficient));
        } else {
            il.append(new SIPUSH((short)coefficient));
        }

        il.append(new IMUL());
        il.append(new ICONST(4));
        if (coefficient <= 5 && coefficient >= -1) {
            il.append(new ICONST(coefficient));
        } else if (coefficient < 128 && coefficient >= -128) {
            il.append(new BIPUSH((byte)coefficient));
        } else {
            il.append(new SIPUSH((short)coefficient));
        }

        il.append(new IMUL());
        il.append(new IREM());
        il.append(new IFNE((InstructionHandle)null));
        return il;
    }

    private InstructionList add(int[] varNums, int chosen_op, int coefficient) {
        InstructionList insert = null;
        switch(chosen_op) {
            case 0:
                insert = this.createOP1(varNums[0], varNums[1], coefficient);
                break;
            case 1:
                insert = this.createOP2(varNums[0], coefficient);
                break;
            case 2:
                insert = this.createOP3(varNums[0], coefficient);
                break;
            case 3:
                insert = this.createOP4(varNums[0], coefficient);
                break;
            case 4:
                insert = this.createOP5(varNums[0], coefficient);
                break;
            case 5:
                insert = this.createOP6(varNums[0], coefficient);
                break;
            case 6:
                insert = this.createOP7(varNums[0], coefficient);
                break;
            case 7:
                insert = this.createOP8(varNums[0], coefficient);
                break;
            case 8:
                insert = this.createOP9(varNums[0], coefficient);
                break;
            default:
                System.out.println("Watermark values are too large. Cannot watermark.");
        }

        return insert;
    }

    public InstructionList createOpaqueInsts(int wmValue, ArrayList variable) {
        InstructionList il = null;
        int chosen_op;
        int coff;
        if (wmValue == 0) {
            chosen_op = 3;
            coff = 0;
        } else {
            int odd_or_even = wmValue % 2;
            int even_array_len;
            int index;
            if (odd_or_even == this.EVEN_OP) {
                even_array_len = this.EVEN_OPS.length;
                index = Math.abs(this.op_generator.nextInt()) % (even_array_len - 1);
                chosen_op = this.EVEN_OPS[index];
            } else {
                even_array_len = this.ODD_OPS.length;
                index = this.op_generator.nextInt() % (even_array_len - 1);
                chosen_op = this.ODD_OPS[index];
            }

            coff = (wmValue - (Integer)this.constOP.get(chosen_op)) / 2;
        }

        LocalVariableInstruction lv1 = (LocalVariableInstruction)variable.get(0);
        int[] varNums;
        if (chosen_op == 0) {
            varNums = new int[2];
            LocalVariableInstruction lv2 = (LocalVariableInstruction)variable.get(1);
            varNums[0] = lv1.getIndex();
            varNums[1] = lv2.getIndex();
        } else {
            varNums = new int[]{lv1.getIndex()};
        }

        il = this.add(varNums, chosen_op, coff);
        return il;
    }

    public int isOpaque(ArrayList instructions) {
        //int value = true;
        int value;
        if ((value = this.check1(instructions)) != -1) {
            return value;
        } else if ((value = this.check2(instructions)) != -1) {
            return value;
        } else if ((value = this.check3(instructions)) != -1) {
            return value;
        } else if ((value = this.check4(instructions)) != -1) {
            return value;
        } else if ((value = this.check5(instructions)) != -1) {
            return value;
        } else if ((value = this.check6(instructions)) != -1) {
            return value;
        } else if ((value = this.check7(instructions)) != -1) {
            return value;
        } else if ((value = this.check8(instructions)) != -1) {
            return value;
        } else {
            return (value = this.check9(instructions)) != -1 ? value : value;
        }
    }

    private int check1(ArrayList instructions) {
        int value = -1;
        int instLen = instructions.size();
        InstructionHandle ih = null;
        Instruction inst = null;
        if (instLen != 15 && instLen != 19) {
            return -1;
        } else {
            ih = (InstructionHandle)instructions.get(0);
            inst = ih.getInstruction();
            if (!(inst instanceof ILOAD)) {
                return -1;
            } else {
                ih = (InstructionHandle)instructions.get(1);
                inst = ih.getInstruction();
                if (!(inst instanceof ILOAD)) {
                    return -1;
                } else {
                    ih = (InstructionHandle)instructions.get(2);
                    inst = ih.getInstruction();
                    if (!(inst instanceof IMUL)) {
                        return -1;
                    } else {
                        ih = (InstructionHandle)instructions.get(3);
                        inst = ih.getInstruction();
                        if (!(inst instanceof BIPUSH)) {
                            return -1;
                        } else {
                            BIPUSH biinst = (BIPUSH)inst;
                            value = value + biinst.getValue().intValue();
                            ih = (InstructionHandle)instructions.get(4);
                            inst = ih.getInstruction();
                            if (!(inst instanceof IMUL)) {
                                return -1;
                            } else {
                                ih = (InstructionHandle)instructions.get(5);
                                inst = ih.getInstruction();
                                if (!(inst instanceof ICONST)) {
                                    return -1;
                                } else {
                                    ICONST cinst = (ICONST)inst;
                                    value += cinst.getValue().intValue();
                                    ih = (InstructionHandle)instructions.get(6);
                                    inst = ih.getInstruction();
                                    if (!(inst instanceof ISUB)) {
                                        return -1;
                                    } else {
                                        ih = (InstructionHandle)instructions.get(7);
                                        inst = ih.getInstruction();
                                        if (!(inst instanceof ConstantPushInstruction)) {
                                            return -1;
                                        } else {
                                            ConstantPushInstruction cpinst = (ConstantPushInstruction)inst;
                                            value += cpinst.getValue().intValue();
                                            ih = (InstructionHandle)instructions.get(8);
                                            inst = ih.getInstruction();
                                            if (!(inst instanceof IMUL)) {
                                                return -1;
                                            } else {
                                                ih = (InstructionHandle)instructions.get(9);
                                                inst = ih.getInstruction();
                                                if (!(inst instanceof ILOAD)) {
                                                    return -1;
                                                } else {
                                                    ih = (InstructionHandle)instructions.get(10);
                                                    inst = ih.getInstruction();
                                                    if (!(inst instanceof ILOAD)) {
                                                        return -1;
                                                    } else {
                                                        ih = (InstructionHandle)instructions.get(11);
                                                        inst = ih.getInstruction();
                                                        if (!(inst instanceof IMUL)) {
                                                            return -1;
                                                        } else {
                                                            ih = (InstructionHandle)instructions.get(12);
                                                            inst = ih.getInstruction();
                                                            if (!(inst instanceof ConstantPushInstruction)) {
                                                                return -1;
                                                            } else {
                                                                cpinst = (ConstantPushInstruction)inst;
                                                                value += cpinst.getValue().intValue();
                                                                ih = (InstructionHandle)instructions.get(13);
                                                                inst = ih.getInstruction();
                                                                if (!(inst instanceof IMUL)) {
                                                                    return -1;
                                                                } else {
                                                                    ih = (InstructionHandle)instructions.get(14);
                                                                    inst = ih.getInstruction();
                                                                    return !(inst instanceof IF_ICMPEQ) ? -1 : value + 1;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    private int check2(ArrayList instructions) {
        int value = -1;
        int instLen = instructions.size();
        InstructionHandle ih = null;
        Instruction inst = null;
        if (instLen != 16 && instLen != 12) {
            return -1;
        } else {
            ih = (InstructionHandle)instructions.get(0);
            inst = ih.getInstruction();
            if (!(inst instanceof ILOAD)) {
                return -1;
            } else {
                ih = (InstructionHandle)instructions.get(1);
                inst = ih.getInstruction();
                if (!(inst instanceof ILOAD)) {
                    return -1;
                } else {
                    ih = (InstructionHandle)instructions.get(2);
                    inst = ih.getInstruction();
                    if (!(inst instanceof IMUL)) {
                        return -1;
                    } else {
                        ih = (InstructionHandle)instructions.get(3);
                        inst = ih.getInstruction();
                        if (!(inst instanceof ICONST)) {
                            return -1;
                        } else {
                            ICONST cinst = (ICONST)inst;
                            value = value + cinst.getValue().intValue();
                            ih = (InstructionHandle)instructions.get(4);
                            inst = ih.getInstruction();
                            if (!(inst instanceof IDIV)) {
                                return -1;
                            } else {
                                ih = (InstructionHandle)instructions.get(5);
                                inst = ih.getInstruction();
                                if (!(inst instanceof ConstantPushInstruction)) {
                                    return -1;
                                } else {
                                    ConstantPushInstruction cpinst = (ConstantPushInstruction)inst;
                                    value += cpinst.getValue().intValue();
                                    ih = (InstructionHandle)instructions.get(6);
                                    inst = ih.getInstruction();
                                    if (!(inst instanceof IMUL)) {
                                        return -1;
                                    } else {
                                        ih = (InstructionHandle)instructions.get(7);
                                        inst = ih.getInstruction();
                                        if (!(inst instanceof ICONST)) {
                                            return -1;
                                        } else {
                                            cinst = (ICONST)inst;
                                            value += cinst.getValue().intValue();
                                            ih = (InstructionHandle)instructions.get(8);
                                            inst = ih.getInstruction();
                                            if (!(inst instanceof ConstantPushInstruction)) {
                                                return -1;
                                            } else {
                                                cpinst = (ConstantPushInstruction)inst;
                                                value += cpinst.getValue().intValue();
                                                ih = (InstructionHandle)instructions.get(9);
                                                inst = ih.getInstruction();
                                                if (!(inst instanceof IMUL)) {
                                                    return -1;
                                                } else {
                                                    ih = (InstructionHandle)instructions.get(10);
                                                    inst = ih.getInstruction();
                                                    if (!(inst instanceof IREM)) {
                                                        return -1;
                                                    } else {
                                                        ih = (InstructionHandle)instructions.get(11);
                                                        inst = ih.getInstruction();
                                                        return !(inst instanceof IFNE) ? -1 : value + 1;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    private int check3(ArrayList instructions) {
        int value = -1;
        int instLen = instructions.size();
        InstructionHandle ih = null;
        Instruction inst = null;
        if (instLen != 16 && instLen != 12) {
            return -1;
        } else {
            ih = (InstructionHandle)instructions.get(0);
            inst = ih.getInstruction();
            if (!(inst instanceof ILOAD)) {
                return -1;
            } else {
                ih = (InstructionHandle)instructions.get(1);
                inst = ih.getInstruction();
                if (!(inst instanceof ILOAD)) {
                    return -1;
                } else {
                    ih = (InstructionHandle)instructions.get(2);
                    inst = ih.getInstruction();
                    if (!(inst instanceof ICONST)) {
                        return -1;
                    } else {
                        ICONST cinst = (ICONST)inst;
                        value = value + cinst.getValue().intValue();
                        ih = (InstructionHandle)instructions.get(3);
                        inst = ih.getInstruction();
                        if (!(inst instanceof IADD)) {
                            return -1;
                        } else {
                            ih = (InstructionHandle)instructions.get(4);
                            inst = ih.getInstruction();
                            if (!(inst instanceof IMUL)) {
                                return -1;
                            } else {
                                ih = (InstructionHandle)instructions.get(5);
                                inst = ih.getInstruction();
                                if (!(inst instanceof ConstantPushInstruction)) {
                                    return -1;
                                } else {
                                    ConstantPushInstruction cpinst = (ConstantPushInstruction)inst;
                                    value += cpinst.getValue().intValue();
                                    ih = (InstructionHandle)instructions.get(6);
                                    inst = ih.getInstruction();
                                    if (!(inst instanceof IMUL)) {
                                        return -1;
                                    } else {
                                        ih = (InstructionHandle)instructions.get(7);
                                        inst = ih.getInstruction();
                                        if (!(inst instanceof ICONST)) {
                                            return -1;
                                        } else {
                                            cinst = (ICONST)inst;
                                            value += cinst.getValue().intValue();
                                            ih = (InstructionHandle)instructions.get(8);
                                            inst = ih.getInstruction();
                                            if (!(inst instanceof ConstantPushInstruction)) {
                                                return -1;
                                            } else {
                                                cpinst = (ConstantPushInstruction)inst;
                                                value += cpinst.getValue().intValue();
                                                ih = (InstructionHandle)instructions.get(9);
                                                inst = ih.getInstruction();
                                                if (!(inst instanceof IMUL)) {
                                                    return -1;
                                                } else {
                                                    ih = (InstructionHandle)instructions.get(10);
                                                    inst = ih.getInstruction();
                                                    if (!(inst instanceof IREM)) {
                                                        return -1;
                                                    } else {
                                                        ih = (InstructionHandle)instructions.get(11);
                                                        inst = ih.getInstruction();
                                                        return !(inst instanceof IFNE) ? -1 : value + 1;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    private int check4(ArrayList instructions) {
        int value = -1;
        int instLen = instructions.size();
        InstructionHandle ih = null;
        Instruction inst = null;
        if (instLen != 13 && instLen != 9) {
            return -1;
        } else {
            ih = (InstructionHandle)instructions.get(0);
            inst = ih.getInstruction();
            if (!(inst instanceof ILOAD)) {
                return -1;
            } else {
                ih = (InstructionHandle)instructions.get(1);
                inst = ih.getInstruction();
                if (!(inst instanceof ILOAD)) {
                    return -1;
                } else {
                    ih = (InstructionHandle)instructions.get(2);
                    inst = ih.getInstruction();
                    if (!(inst instanceof IMUL)) {
                        return -1;
                    } else {
                        ih = (InstructionHandle)instructions.get(3);
                        inst = ih.getInstruction();
                        if (!(inst instanceof ConstantPushInstruction)) {
                            return -1;
                        } else {
                            ConstantPushInstruction cpinst = (ConstantPushInstruction)inst;
                            value = value + cpinst.getValue().intValue();
                            ih = (InstructionHandle)instructions.get(4);
                            inst = ih.getInstruction();
                            if (!(inst instanceof IMUL)) {
                                return -1;
                            } else {
                                ih = (InstructionHandle)instructions.get(5);
                                inst = ih.getInstruction();
                                if (!(inst instanceof ICONST)) {
                                    return -1;
                                } else {
                                    ICONST cinst = (ICONST)inst;
                                    value += cinst.getValue().intValue();
                                    ih = (InstructionHandle)instructions.get(6);
                                    inst = ih.getInstruction();
                                    if (!(inst instanceof ConstantPushInstruction)) {
                                        return -1;
                                    } else {
                                        cpinst = (ConstantPushInstruction)inst;
                                        value += cpinst.getValue().intValue();
                                        ih = (InstructionHandle)instructions.get(7);
                                        inst = ih.getInstruction();
                                        if (!(inst instanceof IMUL)) {
                                            return -1;
                                        } else {
                                            ih = (InstructionHandle)instructions.get(8);
                                            inst = ih.getInstruction();
                                            return !(inst instanceof IF_ICMPLT) ? -1 : value + 1;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    private int check5(ArrayList instructions) {
        int value = -1;
        int instLen = instructions.size();
        InstructionHandle ih = null;
        Instruction inst = null;
        if (instLen != 20 && instLen != 16) {
            return -1;
        } else {
            ih = (InstructionHandle)instructions.get(0);
            inst = ih.getInstruction();
            if (!(inst instanceof ILOAD)) {
                return -1;
            } else {
                ih = (InstructionHandle)instructions.get(1);
                inst = ih.getInstruction();
                if (!(inst instanceof ILOAD)) {
                    return -1;
                } else {
                    ih = (InstructionHandle)instructions.get(2);
                    inst = ih.getInstruction();
                    if (!(inst instanceof ICONST)) {
                        return -1;
                    } else {
                        ICONST cinst = (ICONST)inst;
                        value = value + cinst.getValue().intValue();
                        ih = (InstructionHandle)instructions.get(3);
                        inst = ih.getInstruction();
                        if (!(inst instanceof IADD)) {
                            return -1;
                        } else {
                            ih = (InstructionHandle)instructions.get(4);
                            inst = ih.getInstruction();
                            if (!(inst instanceof ILOAD)) {
                                return -1;
                            } else {
                                ih = (InstructionHandle)instructions.get(5);
                                inst = ih.getInstruction();
                                if (!(inst instanceof ICONST)) {
                                    return -1;
                                } else {
                                    cinst = (ICONST)inst;
                                    value += cinst.getValue().intValue();
                                    ih = (InstructionHandle)instructions.get(6);
                                    inst = ih.getInstruction();
                                    if (!(inst instanceof IADD)) {
                                        return -1;
                                    } else {
                                        ih = (InstructionHandle)instructions.get(7);
                                        inst = ih.getInstruction();
                                        if (!(inst instanceof IMUL)) {
                                            return -1;
                                        } else {
                                            ih = (InstructionHandle)instructions.get(8);
                                            inst = ih.getInstruction();
                                            if (!(inst instanceof IMUL)) {
                                                return -1;
                                            } else {
                                                ih = (InstructionHandle)instructions.get(9);
                                                inst = ih.getInstruction();
                                                if (!(inst instanceof ConstantPushInstruction)) {
                                                    return -1;
                                                } else {
                                                    ConstantPushInstruction cpinst = (ConstantPushInstruction)inst;
                                                    value += cpinst.getValue().intValue();
                                                    ih = (InstructionHandle)instructions.get(10);
                                                    inst = ih.getInstruction();
                                                    if (!(inst instanceof IMUL)) {
                                                        return -1;
                                                    } else {
                                                        ih = (InstructionHandle)instructions.get(11);
                                                        inst = ih.getInstruction();
                                                        if (!(inst instanceof ICONST)) {
                                                            return -1;
                                                        } else {
                                                            cinst = (ICONST)inst;
                                                            value += cinst.getValue().intValue();
                                                            ih = (InstructionHandle)instructions.get(12);
                                                            inst = ih.getInstruction();
                                                            if (!(inst instanceof ConstantPushInstruction)) {
                                                                return -1;
                                                            } else {
                                                                cpinst = (ConstantPushInstruction)inst;
                                                                value += cpinst.getValue().intValue();
                                                                ih = (InstructionHandle)instructions.get(13);
                                                                inst = ih.getInstruction();
                                                                if (!(inst instanceof IMUL)) {
                                                                    return -1;
                                                                } else {
                                                                    ih = (InstructionHandle)instructions.get(14);
                                                                    inst = ih.getInstruction();
                                                                    if (!(inst instanceof IREM)) {
                                                                        return -1;
                                                                    } else {
                                                                        ih = (InstructionHandle)instructions.get(15);
                                                                        inst = ih.getInstruction();
                                                                        return !(inst instanceof IFNE) ? -1 : value + 1;
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    private int check6(ArrayList instructions) {
        int value = -1;
        int instLen = instructions.size();
        InstructionHandle ih = null;
        Instruction inst = null;
        if (instLen != 16 && instLen != 12) {
            return -1;
        } else {
            ih = (InstructionHandle)instructions.get(0);
            inst = ih.getInstruction();
            if (!(inst instanceof ILOAD)) {
                return -1;
            } else {
                ih = (InstructionHandle)instructions.get(1);
                inst = ih.getInstruction();
                if (!(inst instanceof ILOAD)) {
                    return -1;
                } else {
                    ih = (InstructionHandle)instructions.get(2);
                    inst = ih.getInstruction();
                    if (!(inst instanceof IMUL)) {
                        return -1;
                    } else {
                        ih = (InstructionHandle)instructions.get(3);
                        inst = ih.getInstruction();
                        if (!(inst instanceof ICONST)) {
                            return -1;
                        } else {
                            ICONST cinst = (ICONST)inst;
                            value = value + cinst.getValue().intValue();
                            ih = (InstructionHandle)instructions.get(4);
                            inst = ih.getInstruction();
                            if (!(inst instanceof IADD)) {
                                return -1;
                            } else {
                                ih = (InstructionHandle)instructions.get(5);
                                inst = ih.getInstruction();
                                if (!(inst instanceof ConstantPushInstruction)) {
                                    return -1;
                                } else {
                                    ConstantPushInstruction cpinst = (ConstantPushInstruction)inst;
                                    value += cpinst.getValue().intValue();
                                    ih = (InstructionHandle)instructions.get(6);
                                    inst = ih.getInstruction();
                                    if (!(inst instanceof IMUL)) {
                                        return -1;
                                    } else {
                                        ih = (InstructionHandle)instructions.get(7);
                                        inst = ih.getInstruction();
                                        if (!(inst instanceof BIPUSH)) {
                                            return -1;
                                        } else {
                                            BIPUSH biinst = (BIPUSH)inst;
                                            value += biinst.getValue().intValue();
                                            ih = (InstructionHandle)instructions.get(8);
                                            inst = ih.getInstruction();
                                            if (!(inst instanceof ConstantPushInstruction)) {
                                                return -1;
                                            } else {
                                                cpinst = (ConstantPushInstruction)inst;
                                                value += cpinst.getValue().intValue();
                                                ih = (InstructionHandle)instructions.get(9);
                                                inst = ih.getInstruction();
                                                if (!(inst instanceof IMUL)) {
                                                    return -1;
                                                } else {
                                                    ih = (InstructionHandle)instructions.get(10);
                                                    inst = ih.getInstruction();
                                                    if (!(inst instanceof IREM)) {
                                                        return -1;
                                                    } else {
                                                        ih = (InstructionHandle)instructions.get(11);
                                                        inst = ih.getInstruction();
                                                        return !(inst instanceof IFEQ) ? -1 : value + 1;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    private int check7(ArrayList instructions) {
        int value = -1;
        int instLen = instructions.size();
        InstructionHandle ih = null;
        Instruction inst = null;
        if (instLen != 18 && instLen != 14) {
            return -1;
        } else {
            ih = (InstructionHandle)instructions.get(0);
            inst = ih.getInstruction();
            if (!(inst instanceof ILOAD)) {
                return -1;
            } else {
                ih = (InstructionHandle)instructions.get(1);
                inst = ih.getInstruction();
                if (!(inst instanceof ILOAD)) {
                    return -1;
                } else {
                    ih = (InstructionHandle)instructions.get(2);
                    inst = ih.getInstruction();
                    if (!(inst instanceof IMUL)) {
                        return -1;
                    } else {
                        ih = (InstructionHandle)instructions.get(3);
                        inst = ih.getInstruction();
                        if (!(inst instanceof ILOAD)) {
                            return -1;
                        } else {
                            ih = (InstructionHandle)instructions.get(4);
                            inst = ih.getInstruction();
                            if (!(inst instanceof IADD)) {
                                return -1;
                            } else {
                                ih = (InstructionHandle)instructions.get(5);
                                inst = ih.getInstruction();
                                if (!(inst instanceof BIPUSH)) {
                                    return -1;
                                } else {
                                    BIPUSH biinst = (BIPUSH)inst;
                                    value = value + biinst.getValue().intValue();
                                    ih = (InstructionHandle)instructions.get(6);
                                    inst = ih.getInstruction();
                                    if (!(inst instanceof IADD)) {
                                        return -1;
                                    } else {
                                        ih = (InstructionHandle)instructions.get(7);
                                        inst = ih.getInstruction();
                                        if (!(inst instanceof ConstantPushInstruction)) {
                                            return -1;
                                        } else {
                                            ConstantPushInstruction cpinst = (ConstantPushInstruction)inst;
                                            value += cpinst.getValue().intValue();
                                            ih = (InstructionHandle)instructions.get(8);
                                            inst = ih.getInstruction();
                                            if (!(inst instanceof IMUL)) {
                                                return -1;
                                            } else {
                                                ih = (InstructionHandle)instructions.get(9);
                                                inst = ih.getInstruction();
                                                if (!(inst instanceof BIPUSH)) {
                                                    return -1;
                                                } else {
                                                    biinst = (BIPUSH)inst;
                                                    value += biinst.getValue().intValue();
                                                    ih = (InstructionHandle)instructions.get(10);
                                                    inst = ih.getInstruction();
                                                    if (!(inst instanceof ConstantPushInstruction)) {
                                                        return -1;
                                                    } else {
                                                        cpinst = (ConstantPushInstruction)inst;
                                                        value += cpinst.getValue().intValue();
                                                        ih = (InstructionHandle)instructions.get(11);
                                                        inst = ih.getInstruction();
                                                        if (!(inst instanceof IMUL)) {
                                                            return -1;
                                                        } else {
                                                            ih = (InstructionHandle)instructions.get(12);
                                                            inst = ih.getInstruction();
                                                            if (!(inst instanceof IREM)) {
                                                                return -1;
                                                            } else {
                                                                ih = (InstructionHandle)instructions.get(13);
                                                                inst = ih.getInstruction();
                                                                return !(inst instanceof IFEQ) ? -1 : value + 1;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    private int check8(ArrayList instructions) {
        int value = -1;
        int instLen = instructions.size();
        InstructionHandle ih = null;
        Instruction inst = null;
        if (instLen != 18 && instLen != 14) {
            return -1;
        } else {
            ih = (InstructionHandle)instructions.get(0);
            inst = ih.getInstruction();
            if (!(inst instanceof ICONST)) {
                return -1;
            } else {
                ICONST cinst = (ICONST)inst;
                value = value + cinst.getValue().intValue();
                ih = (InstructionHandle)instructions.get(1);
                inst = ih.getInstruction();
                if (!(inst instanceof ILOAD)) {
                    return -1;
                } else {
                    ih = (InstructionHandle)instructions.get(2);
                    inst = ih.getInstruction();
                    if (!(inst instanceof ILOAD)) {
                        return -1;
                    } else {
                        ih = (InstructionHandle)instructions.get(3);
                        inst = ih.getInstruction();
                        if (!(inst instanceof IMUL)) {
                            return -1;
                        } else {
                            ih = (InstructionHandle)instructions.get(4);
                            inst = ih.getInstruction();
                            if (!(inst instanceof IMUL)) {
                                return -1;
                            } else {
                                ih = (InstructionHandle)instructions.get(5);
                                inst = ih.getInstruction();
                                if (!(inst instanceof ICONST)) {
                                    return -1;
                                } else {
                                    cinst = (ICONST)inst;
                                    value += cinst.getValue().intValue();
                                    ih = (InstructionHandle)instructions.get(6);
                                    inst = ih.getInstruction();
                                    if (!(inst instanceof IADD)) {
                                        return -1;
                                    } else {
                                        ih = (InstructionHandle)instructions.get(7);
                                        inst = ih.getInstruction();
                                        if (!(inst instanceof ConstantPushInstruction)) {
                                            return -1;
                                        } else {
                                            ConstantPushInstruction cpinst = (ConstantPushInstruction)inst;
                                            value += cpinst.getValue().intValue();
                                            ih = (InstructionHandle)instructions.get(8);
                                            inst = ih.getInstruction();
                                            if (!(inst instanceof IMUL)) {
                                                return -1;
                                            } else {
                                                ih = (InstructionHandle)instructions.get(9);
                                                inst = ih.getInstruction();
                                                if (!(inst instanceof BIPUSH)) {
                                                    return -1;
                                                } else {
                                                    BIPUSH biinst = (BIPUSH)inst;
                                                    value += biinst.getValue().intValue();
                                                    ih = (InstructionHandle)instructions.get(10);
                                                    inst = ih.getInstruction();
                                                    if (!(inst instanceof ConstantPushInstruction)) {
                                                        return -1;
                                                    } else {
                                                        cpinst = (ConstantPushInstruction)inst;
                                                        value += cpinst.getValue().intValue();
                                                        ih = (InstructionHandle)instructions.get(11);
                                                        inst = ih.getInstruction();
                                                        if (!(inst instanceof IMUL)) {
                                                            return -1;
                                                        } else {
                                                            ih = (InstructionHandle)instructions.get(12);
                                                            inst = ih.getInstruction();
                                                            if (!(inst instanceof IREM)) {
                                                                return -1;
                                                            } else {
                                                                ih = (InstructionHandle)instructions.get(13);
                                                                inst = ih.getInstruction();
                                                                return !(inst instanceof IFEQ) ? -1 : value + 1;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    private int check9(ArrayList instructions) {
        int value = 0;
        int instLen = instructions.size();
        InstructionHandle ih = null;
        Instruction inst = null;
        if (instLen != 21 && instLen != 17) {
            return -1;
        } else {
            ih = (InstructionHandle)instructions.get(0);
            inst = ih.getInstruction();
            if (!(inst instanceof ILOAD)) {
                return -1;
            } else {
                ih = (InstructionHandle)instructions.get(1);
                inst = ih.getInstruction();
                if (!(inst instanceof ILOAD)) {
                    return -1;
                } else {
                    ih = (InstructionHandle)instructions.get(2);
                    inst = ih.getInstruction();
                    if (!(inst instanceof IMUL)) {
                        return -1;
                    } else {
                        ih = (InstructionHandle)instructions.get(3);
                        inst = ih.getInstruction();
                        if (!(inst instanceof ILOAD)) {
                            return -1;
                        } else {
                            ih = (InstructionHandle)instructions.get(4);
                            inst = ih.getInstruction();
                            if (!(inst instanceof ICONST)) {
                                return -1;
                            } else {
                                ICONST cinst = (ICONST)inst;
                                value = value + cinst.getValue().intValue();
                                ih = (InstructionHandle)instructions.get(5);
                                inst = ih.getInstruction();
                                if (!(inst instanceof IADD)) {
                                    return -1;
                                } else {
                                    ih = (InstructionHandle)instructions.get(6);
                                    inst = ih.getInstruction();
                                    if (!(inst instanceof IMUL)) {
                                        return -1;
                                    } else {
                                        ih = (InstructionHandle)instructions.get(7);
                                        inst = ih.getInstruction();
                                        if (!(inst instanceof ILOAD)) {
                                            return -1;
                                        } else {
                                            ih = (InstructionHandle)instructions.get(8);
                                            inst = ih.getInstruction();
                                            if (!(inst instanceof ICONST)) {
                                                return -1;
                                            } else {
                                                cinst = (ICONST)inst;
                                                value += cinst.getValue().intValue();
                                                ih = (InstructionHandle)instructions.get(9);
                                                inst = ih.getInstruction();
                                                if (!(inst instanceof IADD)) {
                                                    return -1;
                                                } else {
                                                    ih = (InstructionHandle)instructions.get(10);
                                                    inst = ih.getInstruction();
                                                    if (!(inst instanceof ConstantPushInstruction)) {
                                                        return -1;
                                                    } else {
                                                        ConstantPushInstruction cpinst = (ConstantPushInstruction)inst;
                                                        value += cpinst.getValue().intValue();
                                                        ih = (InstructionHandle)instructions.get(11);
                                                        inst = ih.getInstruction();
                                                        if (!(inst instanceof IMUL)) {
                                                            return -1;
                                                        } else {
                                                            ih = (InstructionHandle)instructions.get(12);
                                                            inst = ih.getInstruction();
                                                            if (!(inst instanceof ICONST)) {
                                                                return -1;
                                                            } else {
                                                                cinst = (ICONST)inst;
                                                                value += cinst.getValue().intValue();
                                                                ih = (InstructionHandle)instructions.get(13);
                                                                inst = ih.getInstruction();
                                                                if (!(inst instanceof ConstantPushInstruction)) {
                                                                    return -1;
                                                                } else {
                                                                    cpinst = (ConstantPushInstruction)inst;
                                                                    value += cpinst.getValue().intValue();
                                                                    ih = (InstructionHandle)instructions.get(14);
                                                                    inst = ih.getInstruction();
                                                                    if (!(inst instanceof IMUL)) {
                                                                        return -1;
                                                                    } else {
                                                                        ih = (InstructionHandle)instructions.get(15);
                                                                        inst = ih.getInstruction();
                                                                        if (!(inst instanceof IREM)) {
                                                                            return -1;
                                                                        } else {
                                                                            ih = (InstructionHandle)instructions.get(16);
                                                                            inst = ih.getInstruction();
                                                                            return !(inst instanceof IFNE) ? -1 : value + 1;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
